﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GBMS.APP;
using KPIS.GERP.GBMS.BLL;
using KPIS.GERP.GBMS.MODEL;
using Telerik.Web.UI;

namespace KPIS.GERP.GBMS.APP_UI.Form
{
    public partial class BGM_Project_Control_Add : System.Web.UI.Page
    {
        private Common.Main main = new Common.Main();
        private ComboBLL combo = new ComboBLL();
        private Project_BLL projectBLL = new Project_BLL();
        private ManageProject manage = new ManageProject();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strBgmProjExpSeq = Request.QueryString["id"];
                string strTitle = Request.QueryString["type"];
                string strCtrlType = Request.QueryString["ctrl_type"];
                string strSendOrReceive = Request.QueryString["send_or_receive"];
                string strJobsiteSeq = Request.QueryString["job_site_seq"];
                string strBgmProjExpCtrlSeq = Request.QueryString["bgm_proj_exp_ctrl_seq"];

                lblBgmProjExpSeq.Text = strBgmProjExpSeq;
                lblType.Text = strTitle;
                lblCtrlType.Text = strCtrlType;
                lblBgmProjExpCtrlSeq.Text = strBgmProjExpCtrlSeq;

                if (strTitle == strCtrlType)
                {
                    if (strSendOrReceive == "S")
                    {
                        strSendOrReceive = "R";
                    }
                    else
                    {
                        strSendOrReceive = "S";
                    }
                }

                lblSendOrReceive.Text = strSendOrReceive;
                lblJobsiteSeq.Text = strJobsiteSeq;
                strTitle = (strTitle == "1" ? "โครงการ <-> กิจกรรมย่อย" : (strTitle == "2" ? "กิจกรรมย่อย <-> สังกัด" : "สังกัด <-> กรม"));
                lblTitle.Text = strTitle;

                LoadData();
            }
        }

        protected void LoadData()
        {
            string strCtrlType = lblCtrlType.Text;
            string strType = lblType.Text;
            string strSendOrReceive = lblSendOrReceive.Text;
            string strBgmProjExpSeq = lblBgmProjExpSeq.Text;

            DataTable dtb = projectBLL.GetDataProjectExpenseBySequence(strBgmProjExpSeq);
            ViewState["dtb"] = dtb;

            if (dtb.Rows.Count > 0)
            {
                lblBgmExpGrpSeq.Text = dtb.Rows[0]["bgm_exp_grp_seq"].ToString();
                lblBgmExpGrpName.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                lblBgmSourceSeq.Text = dtb.Rows[0]["bgm_source_seq"].ToString();
                lblBgmSourceName.Text = dtb.Rows[0]["bgm_source_name"].ToString();
            }

            switch(strType)
            {
                case "1" :
                    liDepartment.Visible = false;
                    liJobsite.Visible = false;
                    liSubAct.Visible = true;
                    liProject.Visible = true;
                    liProject2.Visible = false;

                    if (strCtrlType == "0")
                    {
                        if (strSendOrReceive == "R")
                        {
                            // โอนเงินจากกิจกรรมย่อยเข้าโครงการ
                            SetPanelProject(false);
                            SetPanelSubAct(true);

                            if (dtb.Rows.Count > 0)
                            {
                                lblProjectSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                                lblProjectBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                                //lblProjectBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                                lblProjectBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();
                                lblProjectAmount.Text = Convert.ToDouble(dtb.Rows[0]["amount"]).ToString("#,##0.00");
                                PanelProjectAmountText.Visible = false;

                                LoadDDLSubAct(ddlSubActSubAct, dtb.Rows[0]["bgm_year"].ToString(), dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                                //ClearDDL(ddlSubActBgmProj);
                                //ClearDDL(ddlSubActBgmExpGrp);
                                ClearDDL(ddlSubActBgmExp);
                                lblSubActAmount.Text = "0.00";
                                txtSubActAmount.Text = "0.00";
                                PanelSubActAmountText.Visible = true;
                            }
                        }
                        else
                        {
                            // โอนเงินจากโครงการเข้ากิจกรรมย่อย
                            SetPanelProject(false);
                            SetPanelSubAct(false);

                            if (dtb.Rows.Count > 0)
                            {
                                lblProjectSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                                lblProjectBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                                //lblProjectBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                                lblProjectBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();
                                lblProjectAmount.Text = Convert.ToDouble(dtb.Rows[0]["amount"]).ToString("#,##0.00");
                                txtProjectAmount.Text = Convert.ToDouble(dtb.Rows[0]["amount"]).ToString("#,##0.00");
                                txtProjectAmount.MaxValue = Convert.ToDouble(dtb.Rows[0]["amount"]);
                                PanelProjectAmountText.Visible = true;

                                lblSubActSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                                lblSubActBgmProj.Text = "-";// dtb.Rows[0]["bgm_proj_name"].ToString();
                                //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                                lblSubActBgmExp.Text = "-";// dtb.Rows[0]["bgm_exp_name"].ToString();
                                lblSubActAmount.Text = manage.GetProjectExpenseControlAmount(dtb.Rows[0]["bgm_strat_list_seq"].ToString()
                                    , lblJobsiteSeq.Text
                                    , dtb.Rows[0]["bgm_source_seq"].ToString()
                                    , dtb.Rows[0]["bgm_exp_grp_seq"].ToString()).ToString("#,##0.00");// Convert.ToDouble(dtb.Rows[0]["amount"]).ToString("#,##0.00");
                                PanelSubActAmountText.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        SetPanelProject(true);
                        SetPanelSubAct(false);

                        double dSubActAmount = manage.GetProjectExpenseControlAmountBySeq(lblBgmProjExpCtrlSeq.Text);

                        if (strSendOrReceive == "R")
                        {
                            LoadDDLSubAct(ddlProjectSubAct, dtb.Rows[0]["bgm_year"].ToString(), dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                            //ClearDDL(ddlProjectBgmProj);
                            //ClearDDL(ddlProjectBgmExpGrp);
                            ClearDDL(ddlProjectBgmExp);
                            lblProjectAmount.Text = "0.00";
                            txtProjectAmount.Text = "0.00";
                            PanelProjectAmountText.Visible = true;

                            lblSubActSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                            lblSubActBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                            //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                            lblSubActBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();
                            lblSubActAmount.Text = dSubActAmount.ToString("#,##0.00");
                            PanelSubActAmountText.Visible = false;
                        }
                        else
                        {
                            LoadDDLSubAct(ddlProjectSubAct, dtb.Rows[0]["bgm_year"].ToString(), dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                            //ClearDDL(ddlProjectBgmProj);
                            //ClearDDL(ddlProjectBgmExpGrp);
                            ClearDDL(ddlProjectBgmExp);
                            lblProjectAmount.Text = "0.00";
                            txtProjectAmount.Text = "0.00";
                            PanelProjectAmountText.Visible = false;

                            lblSubActSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                            lblSubActBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                            //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                            lblSubActBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();
                            
                            lblSubActAmount.Text = dSubActAmount.ToString("#,##0.00");
                            txtSubActAmount.Text = dSubActAmount.ToString("#,##0.00");
                            txtSubActAmount.MaxValue = dSubActAmount;
                            PanelSubActAmountText.Visible = true;
                        }
                    }
                    break;
                case "2" :
                    liDepartment.Visible = false;
                    liJobsite.Visible = true;
                    liSubAct.Visible = true;
                    liProject.Visible = false;
                    liProject2.Visible = false;

                    if (strCtrlType == "1")
                    {
                        SetPanelSubAct(false);
                        SetPanelJobsite(false);

                        double dSubActAmount = manage.GetProjectExpenseControlAmountBySeq(lblBgmProjExpCtrlSeq.Text);

                        lblSubActSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblSubActBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                        //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                        lblSubActBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();

                        lblSubActAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtSubActAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtSubActAmount.MaxValue = dSubActAmount;
                        PanelSubActAmountText.Visible = true;

                        LoadDDLSubAct(ddlJobsiteSubAct, dtb.Rows[0]["bgm_year"].ToString(), dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                        ClearDDL(ddlJobsiteBgmExp);
                        lblJobsiteAmount.Text = "0.00";
                        txtJobsiteAmount.Text = "0.00";
                        PanelJobsiteAmountText.Visible = false;

                        lblJobsiteSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblJobsiteBgmProj.Text = "-";
                        lblJobsiteBgmExp.Text = "-";
                    }
                    else
                    {
                        SetPanelSubAct(true);
                        SetPanelJobsite(false);

                        double dSubActAmount = manage.GetProjectExpenseControlAmountBySeq(lblBgmProjExpCtrlSeq.Text);

                        LoadDDLSubAct(ddlSubActSubAct, dtb.Rows[0]["bgm_year"].ToString(), null);//dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                        ClearDDL(ddlSubActBgmExp);
                        lblSubActAmount.Text = "0.00";
                        txtSubActAmount.Text = "0.00";
                        PanelSubActAmountText.Visible = false;

                        lblJobsiteSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblJobsiteBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                        //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                        lblJobsiteBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();

                        lblJobsiteAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtJobsiteAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtJobsiteAmount.MaxValue = dSubActAmount;
                        PanelJobsiteAmountText.Visible = true;
                    }
                    break;
                case "3" :
                    liDepartment.Visible = true;
                    liJobsite.Visible = true;
                    liSubAct.Visible = false;
                    liProject.Visible = false;
                    liProject2.Visible = false;

                    if (strCtrlType == "2")
                    {
                        SetPanelJobsite(false);
                        SetPanelDepartment(false);

                        double dSubActAmount = manage.GetProjectExpenseControlAmountBySeq(lblBgmProjExpCtrlSeq.Text);

                        lblJobsiteSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblJobsiteBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                        //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                        lblJobsiteBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();

                        lblJobsiteAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtJobsiteAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtJobsiteAmount.MaxValue = dSubActAmount;
                        PanelJobsiteAmountText.Visible = true;

                        LoadDDLSubAct(ddlDepartmentSubAct, dtb.Rows[0]["bgm_year"].ToString(), null);//dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                        ClearDDL(ddlDepartmentBgmExp);
                        lblDepartmentAmount.Text = "0.00";
                        txtDepartmentAmount.Text = "0.00";
                        PanelDepartmentAmountText.Visible = false;

                        lblDepartmentSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblDepartmentBgmProj.Text = "-";
                        lblDepartmentBgmExp.Text = "-";
                    }
                    else
                    {
                        SetPanelJobsite(true);
                        SetPanelDepartment(false);

                        double dSubActAmount = manage.GetProjectExpenseControlAmountBySeq(lblBgmProjExpCtrlSeq.Text);

                        LoadDDLSubAct(ddlJobsiteSubAct, dtb.Rows[0]["bgm_year"].ToString(), null);//dtb.Rows[0]["bgm_strat_list_seq"].ToString());
                        ClearDDL(ddlJobsiteBgmExp);
                        lblJobsiteAmount.Text = "0.00";
                        txtJobsiteAmount.Text = "0.00";
                        PanelJobsiteAmountText.Visible = false;

                        lblDepartmentSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                        lblDepartmentBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                        //lblSubActBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                        lblDepartmentBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();

                        lblDepartmentAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtDepartmentAmount.Text = dSubActAmount.ToString("#,##0.00");
                        txtDepartmentAmount.MaxValue = dSubActAmount;
                        PanelDepartmentAmountText.Visible = true;
                    }
                    break;
                case "4" :
                    liDepartment.Visible = false;
                    liJobsite.Visible = false;
                    liSubAct.Visible = false;
                    liProject.Visible = true;
                    liProject2.Visible = true;

                    SetPanelProject(false);
                    SetPanelProject2();

                    lblProjectSubAct.Text = dtb.Rows[0]["bgm_strat_list_name"].ToString();
                    lblProjectBgmProj.Text = dtb.Rows[0]["bgm_proj_name"].ToString();
                    //lblProjectBgmExpGrp.Text = dtb.Rows[0]["bgm_exp_grp_name"].ToString();
                    lblProjectBgmExp.Text = dtb.Rows[0]["bgm_exp_name"].ToString();

                    double dAmount = Convert.ToDouble(dtb.Rows[0]["amount"]);

                    lblProjectAmount.Text = dAmount.ToString("#,##0.00");
                    txtProjectAmount.Text = dAmount.ToString("#,##0.00");
                    txtProjectAmount.MaxValue = dAmount;
                    PanelProjectAmountText.Visible = true;

                    LoadDDLSubAct(ddlProjectSubAct2, dtb.Rows[0]["bgm_year"].ToString(), null);
                    ClearDDL(ddlProjectBgmProj2);
                    ClearDDL(ddlProjectBgmExp2);
                    PanelProjectAmountText2.Visible = false;
                    break;
            }
        }

        protected void LoadDDLSubAct(RadComboBox ddl, string bgm_year, string bgm_strat_list_seq)
        {
            ddl.DataSource = combo.ListStrategy(bgm_year);
            ddl.DataBind();

            main.InsertEmptyDDLSelect(ddl);

            if (string.IsNullOrEmpty(bgm_strat_list_seq))
            {
                ddl.SelectedIndex = 0;
                ddl.Enabled = true;
            }
            else
            {
                ddl.SelectedValue = bgm_strat_list_seq;
                //ddl.Text += bgm_strat_list_seq.ToString();
                ddl.Enabled = false;

                switch (ddl.ID)
                {
                    case "ddlProjectSubAct":
                        ddlProjectSubAct_SelectedIndexChanged(null, null);
                        break;
                    case "ddlSubActSubAct":
                        ddlSubActSubAct_SelectedIndexChanged(null, null);
                        break;
                    case "ddlJobsiteSubAct":
                        ddlJobsiteSubAct_SelectedIndexChanged(null, null);
                        break;
                    case "ddlDepartmentSubAct":
                        ddlDepartmentSubAct_SelectedIndexChanged(null, null);
                        break;
                    case "ddlProjectSubAct2":
                        ddlProjectSubAct2_SelectedIndexChanged(null, null);
                        break;
                }
            }
        }

        protected void LoadDDLBgmProj(RadComboBox ddl, string bgm_year, string bgm_strat_list_seq, string bgm_proj_seq, string job_site_seq)
        {
            ddl.DataSource = combo.ListProject(bgm_year, job_site_seq, bgm_strat_list_seq);
            ddl.DataBind();

            main.InsertEmptyDDLSelect(ddl);

            if (string.IsNullOrEmpty(bgm_proj_seq))
            {
                ddl.SelectedIndex = 0;
                ddl.Enabled = true;
            }
            else
            {
                ddl.SelectedValue = bgm_proj_seq;
                ddl.Enabled = false;

                switch (ddl.ID)
                {
                    case "ddlProjectBgmProj":
                        ddlProjectBgmProj_SelectedIndexChanged(null, null);
                        break;
                    case "ddlSubActBgmProj":
                        ddlSubActBgmProj_SelectedIndexChanged(null, null);
                        break;
                    case "ddlJobsiteBgmProj":
                        ddlJobsiteBgmProj_SelectedIndexChanged(null, null);
                        break;
                    case "ddlDepartmentBgmProj":
                        ddlDepartmentBgmProj_SelectedIndexChanged(null, null);
                        break;
                    case "ddlProjectBgmProj2":
                        ddlProjectBgmProj2_SelectedIndexChanged(null, null);
                        break;
                }
            }
        }

        protected void ClearDDL(RadComboBox ddl)
        {
            ddl.Items.Clear();
            ddl.Items.Insert(0, new RadComboBoxItem("-- เลือกรายการด้านบนก่อน --", ""));
        }

        //protected void LoadDDLBgmExpGrp(RadComboBox ddl, string bgm_exp_grp_seq)
        //{
        //    ddl.DataSource = combo.ListExpenseGroup();
        //    ddl.DataBind();

        //    main.InsertEmptyDDLSelect(ddl);

        //    if (string.IsNullOrEmpty(bgm_exp_grp_seq))
        //    {
        //        ddl.SelectedIndex = 0;
        //        ddl.Enabled = true;
        //    }
        //    else
        //    {
        //        ddl.SelectedValue = bgm_exp_grp_seq;
        //        ddl.Enabled = false;
        //    }
        //}

        protected void LoadDDLBgmExp(RadComboBox ddl, string bgm_proj_seq, string bgm_source_seq, string bgm_exp_grp_seq, string bgm_exp_seq)
        {
            string strSendOrReceive = Request.QueryString["send_or_receive"];

            if (strSendOrReceive == "S")
            {
                switch (ddl.ID)
                {
                    case "ddlProjectBgmExp":
                    case "ddlProjectBgmExp2":
                        ddl.DataSource = manage.GetProjectExpense(bgm_proj_seq, bgm_source_seq, bgm_exp_grp_seq);
                        break;
                    case "ddlSubActBgmExp":
                        ddl.DataSource = manage.GetProjectExpenseControl(bgm_proj_seq, bgm_source_seq, bgm_exp_grp_seq, "1");
                        break;
                    case "ddlJobsiteBgmExp":
                        ddl.DataSource = manage.GetProjectExpenseControl(bgm_proj_seq, bgm_source_seq, bgm_exp_grp_seq, "2");
                        break;
                    case "ddlDepartmentBgmExp":
                        ddl.DataSource = manage.GetProjectExpenseControl(bgm_proj_seq, bgm_source_seq, bgm_exp_grp_seq, "3");
                        break;
                }
            }
            else
            {
                ddl.DataSource = manage.GetProjectExpense(bgm_proj_seq, bgm_source_seq, bgm_exp_grp_seq);
            }

            ddl.DataBind();

            main.InsertEmptyDDLSelect(ddl);

            if (string.IsNullOrEmpty(bgm_exp_seq))
            {
                ddl.SelectedIndex = 0;
                ddl.Enabled = true;
            }
            else
            {
                ddl.SelectedValue = bgm_exp_seq;
                ddl.Enabled = false;

                switch (ddl.ID)
                {
                    case "ddlProjectBgmExp":
                        ddlProjectBgmExp_SelectedIndexChanged(null, null);
                        break;
                    case "ddlSubActBgmExp":
                        ddlSubActBgmExp_SelectedIndexChanged(null, null);
                        break;
                    case "ddlJobsiteBgmExp":
                        ddlJobsiteBgmExp_SelectedIndexChanged(null, null);
                        break;
                    case "ddlDepartmentBgmExp":
                        ddlDepartmentBgmExp_SelectedIndexChanged(null, null);
                        break;
                    case "ddlProjectBgmExp2":
                        ddlProjectBgmExp2_SelectedIndexChanged(null, null);
                        break;
                }
            }
        }

        protected void SetPanelProject(bool bEdit)
        {
            PanelProject.Visible = !bEdit;
            PanelProjectEdit.Visible = bEdit;
        }
        protected void SetPanelSubAct(bool bEdit)
        {
            PanelSubAct.Visible = !bEdit;
            PanelSubActEdit.Visible = bEdit;
        }
        protected void SetPanelJobsite(bool bEdit)
        {
            PanelJobsite.Visible = !bEdit;
            PanelJobsiteEdit.Visible = bEdit;
        }
        protected void SetPanelDepartment(bool bEdit)
        {
            PanelDepartment.Visible = !bEdit;
            PanelDepartmentEdit.Visible = bEdit;
        }
        protected void SetPanelProject2()
        {
            PanelProjectEdit2.Visible = true;
        }

        protected void ddlProjectSubAct_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlProjectSubAct.SelectedValue.Length > 0)
            {
                LoadDDLBgmProj(ddlProjectBgmProj, ((DataTable)ViewState["dtb"]).Rows[0]["bgm_year"].ToString(), ddlProjectSubAct.SelectedValue, null, lblJobsiteSeq.Text);
            }

            //ClearDDL(ddlProjectBgmExpGrp);
            ClearDDL(ddlProjectBgmExp);
        }

        protected void ddlProjectBgmProj_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlProjectBgmProj.SelectedValue.Length > 0)
            {
                LoadDDLBgmExp(ddlProjectBgmExp, ddlProjectBgmProj.SelectedValue, lblBgmSourceSeq.Text, lblBgmExpGrpSeq.Text, null);
            }

            //ClearDDL(ddlProjectBgmExpGrp);
            //ClearDDL(ddlProjectBgmExp);
        }

        //protected void ddlProjectBgmExpGrp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        //{

        //}

        protected void ddlProjectBgmExp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (ddlProjectBgmExp.SelectedValue.Length > 0)
            {
                DataTable dtbProjectBgmExp = projectBLL.GetDataProjectExpenseBySequence(ddlProjectBgmExp.SelectedValue);
                if (dtbProjectBgmExp.Rows.Count > 0)
                {
                    double dAmount = Convert.ToDouble(dtbProjectBgmExp.Rows[0]["amount"]);
                    lblProjectAmount.Text = dAmount.ToString("#,##0.00");

                    if (PanelProjectAmountText.Visible)
                    {
                        txtProjectAmount.Text = dAmount.ToString("#,##0.00");
                        txtProjectAmount.MaxValue = dAmount;
                    }
                }
            }
        }

        protected void ddlSubActSubAct_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlSubActSubAct.SelectedValue.Length > 0)
            {
                LoadDDLBgmProj(ddlSubActBgmProj, ((DataTable)ViewState["dtb"]).Rows[0]["bgm_year"].ToString(), ddlSubActSubAct.SelectedValue, null, lblJobsiteSeq.Text);
            }

            //ClearDDL(ddlSubActBgmExpGrp);
            ClearDDL(ddlSubActBgmExp);
        }

        protected void ddlSubActBgmProj_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlSubActBgmProj.SelectedValue.Length > 0)
            {
                LoadDDLBgmExp(ddlSubActBgmExp, ddlSubActBgmProj.SelectedValue, lblBgmSourceSeq.Text, lblBgmExpGrpSeq.Text, null);
            }
        }

        //protected void ddlSubActBgmExpGrp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        //{

        //}

        protected void ddlSubActBgmExp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (ddlSubActBgmExp.SelectedValue.Length > 0)
            {
                double dAmount = manage.GetProjectExpenseControlAmountBySeq(ddlSubActBgmExp.SelectedValue);
                lblSubActAmount.Text = dAmount.ToString("#,##0.00");

                if (PanelSubActAmountText.Visible)
                {
                    txtSubActAmount.Text = dAmount.ToString("#,##0.00");
                    txtSubActAmount.MaxValue = dAmount;
                }
            }
        }

        protected void ddlJobsiteSubAct_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlJobsiteSubAct.SelectedValue.Length > 0)
            {
                LoadDDLBgmProj(ddlJobsiteBgmProj, ((DataTable)ViewState["dtb"]).Rows[0]["bgm_year"].ToString(), ddlJobsiteSubAct.SelectedValue, null, lblJobsiteSeq.Text);
            }

            //ClearDDL(ddlJobsiteBgmExpGrp);
            ClearDDL(ddlJobsiteBgmExp);
        }

        protected void ddlJobsiteBgmProj_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlJobsiteBgmProj.SelectedValue.Length > 0)
            {
                LoadDDLBgmExp(ddlJobsiteBgmExp, ddlJobsiteBgmProj.SelectedValue, lblBgmSourceSeq.Text, lblBgmExpGrpSeq.Text, null);
            }
        }

        //protected void ddlJobsiteBgmExpGrp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        //{

        //}

        protected void ddlJobsiteBgmExp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (ddlJobsiteBgmExp.SelectedValue.Length > 0)
            {
                double dAmount = manage.GetProjectExpenseControlAmountBySeq(ddlJobsiteBgmExp.SelectedValue);
                lblJobsiteAmount.Text = dAmount.ToString("#,##0.00");

                if (PanelJobsiteAmountText.Visible)
                {
                    txtJobsiteAmount.Text = dAmount.ToString("#,##0.00");
                    txtJobsiteAmount.MaxValue = dAmount;
                }
            }
        }

        protected void ddlDepartmentSubAct_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlDepartmentSubAct.SelectedValue.Length > 0)
            {
                LoadDDLBgmProj(ddlDepartmentBgmProj, ((DataTable)ViewState["dtb"]).Rows[0]["bgm_year"].ToString(), ddlDepartmentSubAct.SelectedValue, null, lblJobsiteSeq.Text);
            }

            //ClearDDL(ddlDepartmentBgmExpGrp);
            ClearDDL(ddlDepartmentBgmExp);
        }

        protected void ddlDepartmentBgmProj_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlDepartmentBgmProj.SelectedValue.Length > 0)
            {
                LoadDDLBgmExp(ddlDepartmentBgmExp, ddlDepartmentBgmProj.SelectedValue, lblBgmSourceSeq.Text, lblBgmExpGrpSeq.Text, null);
            }
        }

        //protected void ddlDepartmentBgmExpGrp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        //{

        //}

        protected void ddlDepartmentBgmExp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (ddlDepartmentBgmExp.SelectedValue.Length > 0)
            {
                double dAmount = manage.GetProjectExpenseControlAmountBySeq(ddlDepartmentBgmExp.SelectedValue);
                lblDepartmentAmount.Text = dAmount.ToString("#,##0.00");

                if (PanelDepartmentAmountText.Visible)
                {
                    txtDepartmentAmount.Text = dAmount.ToString("#,##0.00");
                    txtDepartmentAmount.MaxValue = dAmount;
                }
            }
        }

        protected void ddlProjectSubAct2_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlProjectSubAct2.SelectedValue.Length > 0)
            {
                LoadDDLBgmProj(ddlProjectBgmProj2, ((DataTable)ViewState["dtb"]).Rows[0]["bgm_year"].ToString(), ddlProjectSubAct2.SelectedValue, null, null);
            }

            //ClearDDL(ddlProjectBgmExpGrp);
            ClearDDL(ddlProjectBgmExp2);
        }

        protected void ddlProjectBgmProj2_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (((DataTable)ViewState["dtb"]).Rows.Count > 0 && ddlProjectBgmProj2.SelectedValue.Length > 0)
            {
                LoadDDLBgmExp(ddlProjectBgmExp2, ddlProjectBgmProj2.SelectedValue, lblBgmSourceSeq.Text, null, null);
            }

            //ClearDDL(ddlProjectBgmExpGrp);
            //ClearDDL(ddlProjectBgmExp);
        }

        //protected void ddlProjectBgmExpGrp_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        //{

        //}

        protected void ddlProjectBgmExp2_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (ddlProjectBgmExp2.SelectedValue.Length > 0)
            {
                DataTable dtbProjectBgmExp = projectBLL.GetDataProjectExpenseBySequence(ddlProjectBgmExp2.SelectedValue);
                if (dtbProjectBgmExp.Rows.Count > 0)
                {
                    double dAmount = Convert.ToDouble(dtbProjectBgmExp.Rows[0]["amount"]);
                    lblProjectAmount2.Text = dAmount.ToString("#,##0.00");

                    if (PanelProjectAmountText2.Visible)
                    {
                        txtProjectAmount2.Text = dAmount.ToString("#,##0.00");
                        txtProjectAmount2.MaxValue = dAmount;
                    }
                }
            }
        }

        protected void cmdSave_Click(object sender, EventArgs e)
        {
            string strBgmProjExpSeq = lblBgmProjExpSeq.Text;
            string strCtrlType = lblCtrlType.Text;
            string strType = lblType.Text;
            string strSendOrReceive = lblSendOrReceive.Text;
            string strEmpSeq = new SsMng().GetUss(SsMng.SsUserType.EmpSeq);

            string strFromName = "";
            string strToName = "";
            string strFromBgmProjExpCtrlSeq = lblBgmProjExpCtrlSeq.Text;
            string strToBgmProjExpCtrlSeq = "";
            string strToBgmExp = "";
            double dAmount = 0;

            switch (strType)
            {
                case "1":
                    if (strCtrlType == "0")
                    {
                        if (txtProjectAmount.Text.Trim().Length == 0 || txtProjectAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtProjectAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
                        strFromName = "โอนไปกองกลางของกิจกรรมย่อย " + ddlSubActSubAct.Text;
                        projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), "-" + dAmount.ToString(), "2", strEmpSeq);
                        manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "R", dAmount.ToString(), strEmpSeq);
                    }
                    else if (strCtrlType == "1")
                    {
                        strToBgmExp = ddlProjectBgmExp.SelectedValue;

                        if (strToBgmExp.Length == 0)
                        {
                            main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
                            return;
                        }
                        if (txtSubActAmount.Text.Trim().Length == 0 || txtSubActAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtSubActAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlSubActBgmProj.Text + " / " + ddlSubActBgmExp.Text;
                        strFromName = "โอนไปโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
                        projectBLL.UpdateTotalAmountProjectExpense(strToBgmExp, strToName, dAmount.ToString(), dAmount.ToString(), "3", strEmpSeq);
                        manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "1", "S", "-" + dAmount.ToString(), strEmpSeq);
                    }
                    break;
                case "2":
                    if (strCtrlType == "1")
                    {
                        if (txtSubActAmount.Text.Trim().Length == 0 || txtSubActAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtSubActAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlSubActBgmProj.Text + " / " + ddlSubActBgmExp.Text;
                        strFromName = "โอนไปกองกลางของสำนัก";
                        //projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), dAmount.ToString(), "3", strEmpSeq);
                        manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "1", "S", "-" + dAmount.ToString(), strEmpSeq);
                        manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "2", "R", dAmount.ToString(), strEmpSeq);
                    }
                    else if (strCtrlType == "2")
                    {
                        strToBgmExp = ddlSubActBgmExp.SelectedValue;

                        if (strToBgmExp.Length == 0)
                        {
                            main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
                            return;
                        }
                        if (txtJobsiteAmount.Text.Trim().Length == 0 || txtJobsiteAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtJobsiteAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlJobsiteBgmProj.Text + " / " + ddlJobsiteBgmExp.Text;
                        strFromName = "โอนไปโครงการ " + ddlSubActBgmProj.Text + " / " + ddlSubActBgmExp.Text;
                        manage.InsertProjectExpenseControl(null, strToBgmExp, "1", "R", dAmount.ToString(), strEmpSeq);
                        manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "2", "S", "-" + dAmount.ToString(), strEmpSeq);
                    }
                    break;
                case "3":
                    if (strCtrlType == "2")
                    {
                        if (txtJobsiteAmount.Text.Trim().Length == 0 || txtJobsiteAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtJobsiteAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlJobsiteBgmProj.Text + " / " + ddlJobsiteBgmExp.Text;
                        strFromName = "โอนไปกองกลางของกรม";
                        //projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), dAmount.ToString(), "3", strEmpSeq);
                        manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "2", "S", "-" + dAmount.ToString(), strEmpSeq);
                        manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "3", "R", dAmount.ToString(), strEmpSeq);
                    }
                    else if (strCtrlType == "3")
                    {
                        strToBgmExp = ddlJobsiteBgmExp.SelectedValue;

                        if (strToBgmExp.Length == 0)
                        {
                            main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
                            return;
                        }
                        if (txtDepartmentAmount.Text.Trim().Length == 0 || txtDepartmentAmount.Value == null)
                        {
                            main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                            return;
                        }

                        dAmount = txtDepartmentAmount.Value.Value;
                        strToName = "รับโอนจากโครงการ " + ddlDepartmentBgmProj.Text + " / " + ddlDepartmentBgmExp.Text;
                        strFromName = "โอนไปโครงการ " + ddlJobsiteBgmProj.Text + " / " + ddlJobsiteBgmExp.Text;
                        manage.InsertProjectExpenseControl(null, strToBgmExp, "2", "R", dAmount.ToString(), strEmpSeq);
                        manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "3", "S", "-" + dAmount.ToString(), strEmpSeq);
                    }
                    break;
                case "4" :
                    if (txtProjectAmount.Text.Trim().Length == 0 || txtProjectAmount.Value == null)
                    {
                        main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
                        return;
                    }

                    dAmount = txtProjectAmount.Value.Value;
                    strToName = "รับโอนเปลี่ยนแปลงจากโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
                    strFromName = "โอนเปลี่ยนแปลงไปโครงการ " + ddlProjectBgmProj2.Text + " / " + ddlProjectBgmExp2.Text;
                    projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), "-" + dAmount.ToString(), "2", strEmpSeq);
                    projectBLL.UpdateTotalAmountProjectExpense(ddlProjectBgmExp2.SelectedValue, strToName, dAmount.ToString(), dAmount.ToString(), "3", strEmpSeq);
                    break;
            }

            //switch (strCtrlType)
            //{
            //    case "0" :
            //        if (strSendOrReceive == "R")
            //        {
                        
            //        }
            //        else
            //        {
            //            if (txtProjectAmount.Text.Trim().Length == 0 || txtProjectAmount.Value == null)
            //            {
            //                main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                return;
            //            }

            //            dAmount = txtProjectAmount.Value.Value;
            //            strToName = "รับโอนจากโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
            //            strFromName = "โอนไปกองกลางของกิจกรรมย่อย " + ddlSubActSubAct.Text;
            //            projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), "-" + dAmount.ToString(), "2", strEmpSeq);
            //            manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "R", dAmount.ToString(), strEmpSeq);
            //        }
            //        break;
            //    case "1" :
            //        if (strSendOrReceive == "R")
            //        {
            //            if (strType == "1")
            //            {
            //                strFromBgmProjExpCtrlSeq = ddlSubActBgmExp.SelectedValue;

            //                if (strFromBgmProjExpCtrlSeq.Length == 0)
            //                {
            //                    main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
            //                    return;
            //                }
            //                if (txtProjectAmount.Text.Trim().Length == 0 || txtProjectAmount.Value == null)
            //                {
            //                    main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                    return;
            //                }

            //                dAmount = txtProjectAmount.Value.Value;
            //                //strToName = "รับโอนจากโครงการ " + ddlSubActBgmProj.Text + " / " + ddlSubActBgmExp.Text;
            //                strFromName = "โอนไปกองกลางของกิจกรรมย่อย " + lblSubActSubAct.Text;
            //                projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strToName, dAmount.ToString(), "-" + dAmount.ToString(), "2", strEmpSeq);
            //                manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "R", dAmount.ToString(), strEmpSeq);
            //            }
            //            else
            //            {
            //                strFromBgmProjExpCtrlSeq = ddlJobsiteBgmExp.SelectedValue;

            //                if (strFromBgmProjExpCtrlSeq.Length == 0)
            //                {
            //                    main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
            //                    return;
            //                }
            //                if (txtJobsiteAmount.Text.Trim().Length == 0 || txtJobsiteAmount.Value == null)
            //                {
            //                    main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                    return;
            //                }

            //                dAmount = txtJobsiteAmount.Value.Value;
            //                //strToName = "รับโอนจากโครงการ " + ddlSubActBgmProj.Text + " / " + ddlSubActBgmExp.Text;
            //                //strFromName = "โอนไปกองกลางของกิจกรรมย่อย " + lblSubActSubAct.Text;
            //                //projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strToName, dAmount.ToString(), "-" + dAmount.ToString(), "2", strEmpSeq);
            //                manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "R", dAmount.ToString(), strEmpSeq);
            //                manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "2", "R", "-" + dAmount.ToString(), strEmpSeq);
            //            }
            //        }
            //        else
            //        {
            //            if (strType == "1")
            //            {
            //                if (txtProjectAmount.Text.Trim().Length == 0 || txtProjectAmount.Value == null)
            //                {
            //                    main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                    return;
            //                }

            //                dAmount = txtProjectAmount.Value.Value;
            //                strToName = "รับโอนจากโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
            //                strFromName = "โอนไปกองกลางของสำนัก";
            //                projectBLL.UpdateTotalAmountProjectExpense(strBgmProjExpSeq, strFromName, dAmount.ToString(), dAmount.ToString(), "3", strEmpSeq);
            //                manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "S", "-" + dAmount.ToString(), strEmpSeq);
            //            }
            //            else
            //            {
            //            }
            //        }
            //        break;
            //    case "2" :
            //        if (strSendOrReceive == "R")
            //        {
            //            strFromBgmProjExpCtrlSeq = ddlJobsiteBgmExp.SelectedValue;

            //            if (strFromBgmProjExpCtrlSeq.Length == 0)
            //            {
            //                main.MessageAlert(Page, "กรุณาเลือกค่าใช้จ่ายที่ต้องการ");
            //                return;
            //            }
            //            if (txtJobsiteAmount.Text.Trim().Length == 0 || txtJobsiteAmount.Value == null)
            //            {
            //                main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                return;
            //            }

            //            dAmount = txtJobsiteAmount.Value.Value;
            //            strToName = "รับโอนจากกิจกรรมย่อย " + ddlJobsiteSubAct.Text + " / " + ddlJobsiteSubAct.Text;
            //            strFromName = "โอนไปกิจกรรมย่อย " + ddlSubActSubAct.Text + " / " + ddlSubActSubAct.Text;
            //            manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "1", "S", dAmount.ToString(), strEmpSeq);
            //            manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "2", "S", "-" + dAmount.ToString(), strEmpSeq);
            //        }
            //        else
            //        {
            //            if (txtSubActAmount.Text.Trim().Length == 0 || txtSubActAmount.Value == null)
            //            {
            //                main.MessageAlert(Page, "กรุณากรอกจำนวนเงินที่ต้องการ");
            //                return;
            //            }

            //            dAmount = txtSubActAmount.Value.Value;
            //            strToName = "รับโอนจากโครงการ " + ddlProjectBgmProj.Text + " / " + ddlProjectBgmExp.Text;
            //            strFromName = "โอนไปกองกลางของสำนัก";
            //            manage.InsertProjectExpenseControl(strFromBgmProjExpCtrlSeq, strBgmProjExpSeq, "1", "R", "-" + dAmount.ToString(), strEmpSeq);
            //            manage.InsertProjectExpenseControl(null, strBgmProjExpSeq, "2", "R", dAmount.ToString(), strEmpSeq);
            //        }
            //        break;
            //    case "3" :
            //        if (strSendOrReceive == "R")
            //        {
            //        }
            //        else
            //        {
            //        }
            //        break;
            //}

            ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", true);
        }
    }
}